<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" />
    <title>添加管理员</title>
    <link rel="stylesheet" href="{{asset('/addons/jquery-weui-build/css/weui.min.css')}}">
    <link rel="stylesheet" href="{{asset('/addons/jquery-weui-build/css/jquery-weui.css')}}">
    <link rel="stylesheet" href="{{asset('/css/system/iconfont.css')}}">
    <link rel="stylesheet" href="{{asset('/css/system/common.css')}}">
    {{--<link rel="stylesheet" href="{{asset('/css/system/add-manage.css')}}">--}}
    <link rel="stylesheet" href="/css/system/add-manage.css?v=20181221">
    @include('sysadmin.head')
    <style>
        .show-hidden{
            z-index:999;
        }
    </style>
</head>
<body ontouchstart>
<div class="mian-container">
    <div class="add-manage">
       <div class="center-list weui-cells weui-cells_checkbox">
           @foreach($tongxunlu as $t)
               <div class="section-list">
                   <h3 class="h3-title"><img class="con-img" src="{{asset('img/list-user1.png')}}">{{$t['group_name']}}</h3>
                   @foreach($t['member'] as $m)
                       <label class="ul sort_list weui-cell weui-check__label">
                           <div class="weui-cell__hd">
                               <input type="checkbox" class="weui-check" name="checkbox1" data-id="{{$m['id']}}" @if(in_array($m['id'],$admins)) checked @endif>
                               <i class="weui-icon-checked"></i>
                           </div>
                           <div class="num_logo weui-cell__bd">
                               <img class="sec-img" src="{{userlogo($m['id'])}}">
                               <span class="num_name">{{$m['qw_name']}}</span>
                           </div>
                           <div class="weui-cell__ft">
                              {{-- <span class="circle-span span-reward">奖</span>--}}
                           </div>
                       </label>
                   @endforeach
                   @if(isset($t['child']))
                       @foreach($t['child'] as $c)
                           <div class="second-list">
                               <h3 class="h3-title"><img class="con-img" src="{{asset('/img/list-user1.png')}}">{{$c['group_name']}}</h3>
                               @foreach($c['member'] as $cm)
                                   <label class="ul sort_list weui-cell weui-check__label">
                                       <div class="weui-cell__hd">
                                           <input type="checkbox" class="weui-check" name="checkbox1" data-id="{{$cm['id']}}" @if(in_array($cm['id'],$admins)) checked @endif>
                                           <i class="weui-icon-checked"></i>
                                       </div>
                                       <div class="num_logo weui-cell__bd">
                                           <img class="sec-img" src="{{userlogo($cm['id'])}}">
                                           <span class="num_name">{{$cm['qw_name']}}</span>
                                           <i class="icon iconfont icon-qizi"></i>
                                       </div>
                                       <div class="weui-cell__ft">
                                           {{--<span class="circle-span span-reward">奖</span>
                                           <span class="circle-span span-exam">考</span>
                                           <span class="circle-span span-score">绩</span>--}}
                                       </div>
                                   </label>
                               @endforeach
                               @foreach($c['child'] as $cc)
                                   <div class="third-list">
                                       <h3 class="h3-title"><img class="con-img" src="{{asset('/img/list-user1.png')}}">{{$cc['group_name']}}</h3>
                                       @foreach($cc['member'] as $ccm)
                                           <label class="ul sort_list weui-cell weui-check__label">
                                               <div class="weui-cell__hd">
                                                   <input type="checkbox" class="weui-check" name="checkbox1" data-id="{{$ccm['id']}}" @if(in_array($ccm['id'],$admins)) checked @endif>
                                                   <i class="weui-icon-checked"></i>
                                               </div>
                                               <div class="num_logo weui-cell__bd">
                                                   <img class="sec-img" src="{{userlogo($ccm['id'])}}">
                                                   <span class="num_name">{{$ccm['qw_name']}}</span>
                                                   <i class="icon iconfont icon-qizi"></i>
                                               </div>
                                               <div class="weui-cell__ft">
                                                   {{--<span class="circle-span span-reward">奖</span>--}}
                                               </div>
                                           </label>
                                       @endforeach
                                   </div>
                               @endforeach
                           </div>
                       @endforeach
                   @endif
               </div>
           @endforeach
       </div>
    </div>
    <input type="hidden" name="roleid" value="{{$roleid}}">
    {!! csrf_field() !!}
    <!-- 总计选择-->
   <div class="total-num weui-cells">
        <div class="weui-cell">
            <div class="weui-cell__bd">
              <p>已选择：<span class="select-num"></span></p>
            </div>
            <div class="weui-cell__ft"><a class="num-btn" href="javascript:void(0);">完成</a></div>
        </div>
    </div>
    <!--阴影遮罩-->
    <div class="list-shadow"></div>
     <!-- 隐藏考核按钮部分-->
    @include('sysadmin.admin-caidan')
</div>
<script src="{{asset('/kaohe/js/jquery-2.1.4.min.js')}}"></script>
<script src="{{asset('/addons/jquery-weui-build/js/fastclick.js')}}"></script>
<script>
    $(function() {
        document.documentElement.style.fontSize = document.documentElement.clientWidth / 7.5 + 'px';
        FastClick.attach(document.body);
    });
</script>
<script src="{{asset('/addons/jquery-weui-build/js/jquery-weui.min.js')}}"></script>
<script>
    $(document).ready(function () {
        $('.h3-title').click(function(){
            $(this).toggleClass('ah3-title');           
            $(this).siblings('.ul').toggle();
        });


        var num=0;
        $('.weui-check').each(function(){
            if($(this).prop("checked")){
                num += 1;
            }
        });
        $('.select-num').text(num);
        $('.total-num').css('display','block');
        $('body').on('click','.weui-check',function(){
            var clas=$(this).parent().next().find('img').attr('class')
             if ($(this).prop("checked")) {
                 $('.total-num').css('display','block');   
                 $('.add-manage').css('padding-bottom','115px');
                 num++;
                 
             } else {                            
                 num--;
             }
            if(num==0){
                //$('.total-num').css('display','none');
                $('.add-manage').css('padding-bottom','65px');
            }
            $('.select-num').text(num);
        })
        $('.num-btn').click(function(){
            $('.total-num').css('display','none');
             $('.add-manage').css('padding-bottom','65px');
            var token = $('input[name=_token]').val();
            var roleid = $('input[name=roleid]').val();
            var ids = [];
            $('.center-list input[type="checkbox"]').each(function () {
                if ($(this).is(':checked')) {
                    ids.push($(this).attr('data-id'));
                }
            });
            if(ids.length == 0){
                $.toast('请选择一项',"text");
                return false;
            }
            $.ajax({
                'url': '/sysadmin/permission/add-admin?_token='+token+'&roleid='+roleid,
                'type': 'POST',
                'data': {'userid':JSON.stringify(ids)},
                error: function (request) {
                    $.toast('网络错误',"text");
                },
                success: function (data) {
                    if (data.status == 'success') {
                        $.toast("操作成功");
                        window.location.href='/sysadmin/permission/show-admins?roleid='+roleid;
                    } else {
                        $.toast(data.msg,"text");
                    }
                },
            });
        });
        $('.kaohe-item').click(function(){
            $('.show-hidden').toggle();
        })
        $('.admin-item').click(function(){
            $('.front-show-hidden').toggle();
        });
        
    })
</script>
</body>
</html>